package com.yxy.controller.admin;

import com.yxy.common.Result;
import com.yxy.constant.RequestMapperConstant;
import com.yxy.domain.dto.ResourcesDTO;
import com.yxy.domain.po.Resources;
import com.yxy.domain.vo.ResourcesVO;
import com.yxy.service.ResourcesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(RequestMapperConstant.ADMIN_REQUEST_MAPPER + "resources")
@Slf4j
public class ResourceController {

    @Autowired
    private ResourcesService resourcesService;

    /**
     * 获取资源列表
     * @return
     */
    @GetMapping
    public Result<ResourcesVO> list(){
        log.info("获取资源列表");
        ResourcesVO vo = resourcesService.list();
        return Result.success("", vo);
    }

    /**
     * 更新资源
     * @param resourcesDTO
     * @return
     */
    @PutMapping
    public Result update(@RequestBody ResourcesDTO resourcesDTO){
        log.info("更新资源");
        resourcesService.update(resourcesDTO);
        return Result.success("更换成功");
    }
}
